package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.ExpressCompany;
import com.pgybook.db.entity.domain.ExpressCompanyEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface ExpressCompanyMapper {
    int countByExample(ExpressCompanyEx example);

    int deleteByExample(ExpressCompanyEx example);

    @Delete({
            "delete from expresscompany",
            "where EXPCOMID = #{expcomid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer expcomid);

    @Insert({
            "insert into expresscompany (NAME, STATUS, ",
            "CODE, ADDRESS, CONTACT, ",
            "PHONE, DESCRIPTION, ",
            "CRTSTAFF, CRTTIME, ",
            "UPDSTAFF, UPDTIME)",
            "values (#{name,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ",
            "#{code,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, #{contact,jdbcType=VARCHAR}, ",
            "#{phone,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, ",
            "#{crtstaff,jdbcType=INTEGER}, #{crttime,jdbcType=TIMESTAMP}, ",
            "#{updstaff,jdbcType=INTEGER}, #{updtime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "expcomid", before = false, resultType = Integer.class)
    int insert(ExpressCompany record);

    int insertSelective(ExpressCompany record);

    List<ExpressCompany> selectByExample(ExpressCompanyEx example);

    @Select({
            "select",
            "EXPCOMID, NAME, STATUS, CODE, ADDRESS, CONTACT, PHONE, DESCRIPTION, CRTSTAFF, ",
            "CRTTIME, UPDSTAFF, UPDTIME",
            "from expresscompany",
            "where EXPCOMID = #{expcomid,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    ExpressCompany selectByPrimaryKey(Integer expcomid);

    int updateByExampleSelective(@Param("record") ExpressCompany record, @Param("example") ExpressCompanyEx example);

    int updateByExample(@Param("record") ExpressCompany record, @Param("example") ExpressCompanyEx example);

    int updateByPrimaryKeySelective(ExpressCompany record);

    @Update({
            "update expresscompany",
            "set NAME = #{name,jdbcType=VARCHAR},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "CODE = #{code,jdbcType=VARCHAR},",
            "ADDRESS = #{address,jdbcType=VARCHAR},",
            "CONTACT = #{contact,jdbcType=VARCHAR},",
            "PHONE = #{phone,jdbcType=VARCHAR},",
            "DESCRIPTION = #{description,jdbcType=VARCHAR},",
            "CRTSTAFF = #{crtstaff,jdbcType=INTEGER},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "UPDSTAFF = #{updstaff,jdbcType=INTEGER},",
            "UPDTIME = #{updtime,jdbcType=TIMESTAMP}",
            "where EXPCOMID = #{expcomid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(ExpressCompany record);
}
